from django.shortcuts import render_to_response
from models import Task
import transaction

def demo(request):
    
    i = len(request.zodb.root)
    
    
    #add tasks
    task = Task('working')
    request.zodb.root[i] = task
    i += 1
    
    task = Task('reading')
    request.zodb.root[i] = task
    
    transaction.commit()
    
    
    #show tasks
    tasks = []

    for x in range(len(request.zodb.root)):
        tasks.append(request.zodb.root[x])
    
    return render_to_response('demo.html',{'tasks': tasks})

